package com.hc.sort.manager;

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;
import com.hc.sort.server.pojo.*;
import com.hc.sort.server.service.*;
import java.util.*;
import java.util.List;
import java.awt.event.*;

public class ManagerUI extends JFrame {
	// 业务层的对象
	BusinessTypeService businessTypeService = new BusinessTypeServiceImpl();
	BusinessWindowService wDaoService = new BusinessWindowServiceImpl();
	CallerService callerService = new CallerServiceImpl();

	private JPanel contentPane;
	private JPanel panelTop;
	private JTextField textFieldSearch;
	private JTable tableBusType;
	JTabbedPane panelRight;
	private String userName;
	private JTextField textBWSearch;
	private JTable tableBW;
	private JTextField textStaffSearch;
	private JTable tableStaff;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ManagerUI frame = new ManagerUI("小明");
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}

		});

	}

	public ManagerUI(String userName) {
		// 调用默认构造函数，初始化界面
//		this();
		this.userName = userName;

		setTitle("排队叫号管理系统-主窗口");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 947, 633);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		panelTop = new JPanel();
		panelTop.setBorder(new LineBorder(new Color(0, 0, 0)));
		panelTop.setBounds(0, 0, 918, 38);
		contentPane.add(panelTop);
		panelTop.setLayout(null);

		JLabel labelTitle = new JLabel("欢迎 " + userName + "，现在是" + new Date().toLocaleString());
		labelTitle.setBounds(552, 10, 356, 18);
		labelTitle.setFont(new Font("宋体", Font.PLAIN, 15));
		panelTop.add(labelTitle);

		JPanel panelBottom = new JPanel();
		panelBottom.setLayout(null);
		panelBottom.setBounds(0, 534, 918, 38);
		contentPane.add(panelBottom);

		JLabel labelBTitle = new JLabel("广东汇才创智科技有限公司版权所有");
		labelBTitle.setFont(new Font("宋体", Font.PLAIN, 15));
		labelBTitle.setBounds(346, 10, 245, 18);
		panelBottom.add(labelBTitle);

		JPanel panelLeft = new JPanel();
		panelLeft.setBorder(new LineBorder(Color.WHITE));
		panelLeft.setBounds(0, 35, 225, 489);
		contentPane.add(panelLeft);
		panelLeft.setLayout(null);

		JButton staffBtn = new JButton("柜员管理");
		staffBtn.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				panelRight.setSelectedIndex(0);
			}
		});
		staffBtn.setFont(new Font("宋体", Font.PLAIN, 15));
		staffBtn.setBounds(43, 33, 139, 27);
		panelLeft.add(staffBtn);

		JButton btnBusType = new JButton("业务类型管理");
		btnBusType.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				panelRight.setSelectedIndex(1);
			}
		});
		btnBusType.setFont(new Font("宋体", Font.PLAIN, 15));
		btnBusType.setBounds(43, 95, 139, 27);
		panelLeft.add(btnBusType);

		JButton btnWindow = new JButton("窗口管理");
		btnWindow.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				panelRight.setSelectedIndex(2);
			}
		});
		btnWindow.setFont(new Font("宋体", Font.PLAIN, 15));
		btnWindow.setBounds(43, 154, 139, 27);
		panelLeft.add(btnWindow);

		JButton btnBusView = new JButton("业务情况查看");
		btnBusView.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				panelRight.setSelectedIndex(3);
			}
		});
		btnBusView.setFont(new Font("宋体", Font.PLAIN, 15));
		btnBusView.setBounds(43, 216, 139, 27);
		panelLeft.add(btnBusView);

		panelRight = new JTabbedPane(JTabbedPane.TOP);
		panelRight.setBorder(new LineBorder(new Color(0, 0, 0)));
		panelRight.setBounds(226, 35, 692, 489);
		contentPane.add(panelRight);

		JPanel panelStaff = new JPanel();
		panelRight.addTab("柜员管理", null, panelStaff, null);
		panelStaff.setLayout(null);

		JPanel panelSta = new JPanel();
		panelSta.setLayout(null);
		panelSta.setBounds(0, 0, 689, 70);
		panelStaff.add(panelSta);

		textStaffSearch = new JTextField();
		textStaffSearch.setColumns(10);
		textStaffSearch.setBounds(10, 10, 188, 21);
		panelSta.add(textStaffSearch);

		JButton btnStaffSearch = new JButton("搜索");
		btnStaffSearch.setFont(new Font("宋体", Font.PLAIN, 14));
		btnStaffSearch.setBounds(223, 10, 101, 21);
		panelSta.add(btnStaffSearch);

		JButton btnStaffAdd = new JButton("新增");
		btnStaffAdd.setFont(new Font("宋体", Font.PLAIN, 14));
		btnStaffAdd.setBounds(223, 41, 101, 21);
		panelSta.add(btnStaffAdd);

		JButton btnStaffModify = new JButton("修改");
		btnStaffModify.setFont(new Font("宋体", Font.PLAIN, 14));
		btnStaffModify.setBounds(445, 41, 101, 21);
		panelSta.add(btnStaffModify);

		JButton btnStaffDelete = new JButton("删除");
		btnStaffDelete.setFont(new Font("宋体", Font.PLAIN, 14));
		btnStaffDelete.setBounds(334, 41, 101, 21);
		panelSta.add(btnStaffDelete);

		JButton btnStaffFlush = new JButton("刷新");
		btnStaffFlush.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				textStaffSearch.setText("");
				StaffData();
			}
		});
		btnStaffFlush.setFont(new Font("宋体", Font.PLAIN, 14));
		btnStaffFlush.setBounds(556, 41, 101, 21);
		panelSta.add(btnStaffFlush);

		JScrollPane scrollPaneStaff = new JScrollPane();
		scrollPaneStaff.setBorder(new LineBorder(new Color(130, 135, 144)));
		scrollPaneStaff.setBounds(0, 70, 689, 322);
		panelStaff.add(scrollPaneStaff);

		tableStaff = new JTable();
		tableStaff.setModel(new DefaultTableModel(
				new Object[][] { { null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null }, { null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null }, { null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null }, },
				new String[] { "\u67DC\u5458\u5DE5\u53F7", "\u67DC\u5458\u59D3\u540D", "\u67DC\u5458\u6027\u522B",
						"\u5165\u804C\u65E5\u671F", "\u51FA\u751F\u65E5\u671F", "\u6700\u540E\u767B\u5F55\u65F6\u95F4",
						"\u6700\u540E\u767B\u5F55IP" }));
		scrollPaneStaff.setViewportView(tableStaff);

		JButton btnStaffHome = new JButton("首页");
		btnStaffHome.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				init();
			}
		});
		btnStaffHome.setFont(new Font("宋体", Font.PLAIN, 14));
		btnStaffHome.setBounds(166, 413, 67, 21);
		panelStaff.add(btnStaffHome);

		JButton btnStaffPrevious = new JButton("上一页");
		btnStaffPrevious.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				init();
			}
		});
		btnStaffPrevious.setFont(new Font("宋体", Font.PLAIN, 14));
		btnStaffPrevious.setBounds(243, 413, 80, 21);
		panelStaff.add(btnStaffPrevious);

		JButton btnStaffNext = new JButton("下一页");
		btnStaffNext.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				init();
			}
		});
		btnStaffNext.setFont(new Font("宋体", Font.PLAIN, 14));
		btnStaffNext.setBounds(333, 413, 80, 21);
		panelStaff.add(btnStaffNext);

		JButton btnStaffLast = new JButton("尾页");
		btnStaffLast.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				init();
			}
		});
		btnStaffLast.setFont(new Font("宋体", Font.PLAIN, 14));
		btnStaffLast.setBounds(423, 413, 67, 21);
		panelStaff.add(btnStaffLast);

		JPanel panelBusType = new JPanel();
		panelRight.addTab("业务类型管理", null, panelBusType, null);
		panelBusType.setLayout(null);

		JPanel panelBusiness = new JPanel();
		panelBusiness.setBounds(0, 0, 689, 70);
		panelBusType.add(panelBusiness);
		panelBusiness.setLayout(null);

		textFieldSearch = new JTextField();
		textFieldSearch.setBounds(10, 10, 188, 21);
		panelBusiness.add(textFieldSearch);
		textFieldSearch.setColumns(10);

		JButton btnBusSearch = new JButton("搜索");
		btnBusSearch.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// 得到搜索的关键字
				String keyWord = textFieldSearch.getText();
				if (keyWord != null && !"".equals(keyWord.trim())) {
					List<BusinessType> busList = businessTypeService.searchByKeyword(keyWord);
					// 显示数据到表中
					DefaultTableModel model = (DefaultTableModel) tableBusType.getModel();

					// 清理表中原有的行
					model.setRowCount(0);
					// 重新显示数据到表格中
					for (int i = 0; i < busList.size(); i++) {
						BusinessType bus = busList.get(i);
						Object[] rowData = { bus.getId(), bus.getCode(), bus.getName(), bus.getLimitCount(),
								bus.getDesc() };

						model.addRow(rowData);
					}
				}
			}
		});
		btnBusSearch.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBusSearch.setBounds(223, 10, 101, 21);
		panelBusiness.add(btnBusSearch);

		JButton btnBusAdd = new JButton("新增");
		btnBusAdd.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				BusinessTypeAddDlg addDlg = new BusinessTypeAddDlg(ManagerUI.this);
				addDlg.setVisible(true);
			}
		});
		btnBusAdd.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBusAdd.setBounds(223, 41, 101, 21);
		panelBusiness.add(btnBusAdd);

		JButton btnBusModify = new JButton("修改");
		btnBusModify.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				int row = tableBusType.getSelectedRow();
				if (row > 0) {
					// 显示添加框
					String code = tableBusType.getValueAt(row, 1).toString();
					String name = tableBusType.getValueAt(row, 2).toString();
					String LimitCount = tableBusType.getValueAt(row, 3).toString();
					String des = tableBusType.getValueAt(row, 4).toString();
					int id = Integer.parseInt(tableBusType.getValueAt(row, 0).toString());
					System.out.println(code + " " + name + " " + LimitCount + " " + des + " " + id);
					BusinessTypeAlterDialog updateDlg = new BusinessTypeAlterDialog(ManagerUI.this, name, LimitCount,
							code, des, id);
					updateDlg.setVisible(true);
				} else {
					JOptionPane.showMessageDialog(null, "请选择一行来更新");
				}
			}
		});
		btnBusModify.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBusModify.setBounds(445, 41, 101, 21);
		panelBusiness.add(btnBusModify);

		JButton btnBusDelete = new JButton("删除");
		btnBusDelete.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				int row = tableBusType.getSelectedRow(); // 返回被选中的行
//				DefaultTableModel model=(DefaultTableModel) tableBusType.getModel();
				if (row > 0) {
					// 根据选择的行号，获取该行数据
					int id = Integer.parseInt(tableBusType.getValueAt(row, 0).toString());
					String busName = tableBusType.getValueAt(row, 2).toString();
					int ret = businessTypeService.delete(id);
					if (ret > 0) {
						JOptionPane.showMessageDialog(null, busName + "删除成功");
					} else {
						JOptionPane.showMessageDialog(null, "删除失败");
					}
					flushData();
				} else {
					JOptionPane.showMessageDialog(null, "请选择一行来删除");
				}
			}
		});
		btnBusDelete.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBusDelete.setBounds(334, 41, 101, 21);
		panelBusiness.add(btnBusDelete);

		JButton btnBusFlush = new JButton("刷新");
		btnBusFlush.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				textFieldSearch.setText("");
				flushData();
			}
		});
		btnBusFlush.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBusFlush.setBounds(556, 41, 101, 21);
		panelBusiness.add(btnBusFlush);

		JScrollPane scrollPaneBusType = new JScrollPane();
		scrollPaneBusType.setBorder(new LineBorder(new Color(130, 135, 144)));
		scrollPaneBusType.setBounds(0, 73, 685, 322);
		panelBusType.add(scrollPaneBusType);

		tableBusType = new JTable();
		tableBusType.setModel(new DefaultTableModel(new Object[][] { { null, null, null, null, null },
				{ null, null, null, null, null }, { null, null, null, null, null }, { null, null, null, null, null },
				{ null, null, null, null, null }, { null, null, null, null, null }, { null, null, null, null, null },
				{ null, null, null, null, null }, { null, null, null, null, null }, { null, null, null, null, null },
				{ null, null, null, null, null }, { null, null, null, null, null }, { null, null, null, null, null },
				{ null, null, null, null, null }, { null, null, null, null, null }, { null, null, null, null, null },
				{ null, null, null, null, null }, { null, null, null, null, null }, { null, null, null, null, null },
				{ null, null, null, null, null }, { null, null, null, null, null }, { null, null, null, null, null }, },
				new String[] { "ID", "\u4E1A\u52A1\u4EE3\u7801", "\u4E1A\u52A1\u540D\u79F0", "\u5F53\u5929\u4E0A\u9650",
						"\u5907\u6CE8" }));
		tableBusType.getColumnModel().getColumn(4).setMinWidth(20);
		tableBusType.setBounds(0, 80, 658, 311);
		scrollPaneBusType.add(tableBusType);
		scrollPaneBusType.setViewportView(tableBusType);

		JButton btnBTHome = new JButton("首页");
		btnBTHome.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				init();
			}
		});
		btnBTHome.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnBTHome.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBTHome.setBounds(193, 413, 67, 21);
		panelBusType.add(btnBTHome);

		JButton btnBTPrevious = new JButton("上一页");
		btnBTPrevious.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				init();
			}
		});
		btnBTPrevious.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBTPrevious.setBounds(270, 413, 80, 21);
		panelBusType.add(btnBTPrevious);

		JButton btnBTNext = new JButton("下一页");
		btnBTNext.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				init();
			}
		});
		btnBTNext.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBTNext.setBounds(360, 413, 80, 21);
		panelBusType.add(btnBTNext);

		JButton btnBTLast = new JButton("尾页");
		btnBTLast.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				init();
			}
		});
		btnBTLast.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBTLast.setBounds(450, 413, 67, 21);
		panelBusType.add(btnBTLast);

		JPanel panelWindows = new JPanel();
		panelRight.addTab("窗口管理", null, panelWindows, null);
		panelWindows.setLayout(null);

		JPanel panelBW = new JPanel();
		panelBW.setLayout(null);
		panelBW.setBounds(0, 0, 685, 70);
		panelWindows.add(panelBW);

		textBWSearch = new JTextField();
		textBWSearch.setColumns(10);
		textBWSearch.setBounds(10, 10, 188, 21);
		panelBW.add(textBWSearch);

		// 窗口管理搜索功能
		JButton btnBWSearch = new JButton("搜索");
		btnBWSearch.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// 得到搜索的关键字
				String keyWord = textBWSearch.getText();
				if (keyWord != null && !"".equals(keyWord.trim())) {
					List<BusinessWindow> windowList = wDaoService.searchByKeyword(keyWord);
					BWData(windowList);
				} else {
					JOptionPane.showMessageDialog(null, "111");
				}
			}
		});
		btnBWSearch.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBWSearch.setBounds(223, 10, 101, 21);
		panelBW.add(btnBWSearch);

		JButton btnBWAdd = new JButton("新增");
		btnBWAdd.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				BusinessWindowAddDialog windowAddDialog = new BusinessWindowAddDialog(ManagerUI.this);
				windowAddDialog.setVisible(true);
			}
		});
		btnBWAdd.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBWAdd.setBounds(223, 41, 101, 21);
		panelBW.add(btnBWAdd);

		JButton btnBWModify = new JButton("修改");
		btnBWModify.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				int row = tableBW.getSelectedRow();
				System.out.println(row);
				if (row >= 0) {
					int id = Integer.parseInt(tableBW.getValueAt(row, 0).toString());
					BusinessWindowAlterDialog windowAlterDialog = new BusinessWindowAlterDialog(ManagerUI.this, id);
					windowAlterDialog.setVisible(true);
				} else {
					JOptionPane.showMessageDialog(null, "请选择一行来编辑");
				}
			}
		});
		btnBWModify.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBWModify.setBounds(445, 41, 101, 21);
		panelBW.add(btnBWModify);

		// 删除
		JButton btnBWDelete = new JButton("删除");
		btnBWDelete.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				int row = tableBW.getSelectedRow();
				if (row < 0) {
					JOptionPane.showMessageDialog(null, "请选择删除的内容");
				} else {
					String id = tableBW.getValueAt(row, 0).toString();
					int ret = wDaoService.delete(Integer.parseInt(id));
					if (ret > 0) {
						JOptionPane.showMessageDialog(null, "删除成功");
						// 刷新窗口的数据
						flushBWData();

					} else {
						JOptionPane.showMessageDialog(null, "删除失败");
					}
				}
			}
		});
		btnBWDelete.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBWDelete.setBounds(334, 41, 101, 21);
		panelBW.add(btnBWDelete);

		JButton btnBWFlush = new JButton("刷新");
		btnBWFlush.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				textBWSearch.setText("");
				flushBWData();
			}
		});
		btnBWFlush.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBWFlush.setBounds(556, 41, 101, 21);
		panelBW.add(btnBWFlush);

		JScrollPane scrollPaneBW = new JScrollPane();
		scrollPaneBW.setBorder(new LineBorder(new Color(130, 135, 144)));
		scrollPaneBW.setBounds(0, 70, 685, 322);
		panelWindows.add(scrollPaneBW);

		tableBW = new JTable();
		tableBW.setModel(
				new DefaultTableModel(
						new Object[][] { { null, null, null, null }, { null, null, null, null },
								{ null, null, null, null }, { null, null, null, null }, { null, null, null, null },
								{ null, null, null, null }, { null, null, null, null }, { null, null, null, null },
								{ null, null, null, null }, { null, null, null, null }, { null, null, null, null },
								{ null, null, null, null }, { null, null, null, null }, { null, null, null, null },
								{ null, null, null, null }, { null, null, null, null }, { null, null, null, null },
								{ null, null, null, null }, { null, null, null, null }, { null, null, null, null },
								{ null, null, null, null }, { null, null, null, null }, },
						new String[] { "窗口号", "业务代码", "业务办理", "业务名称" }));
		scrollPaneBW.setViewportView(tableBW);

		JButton btnBWHome = new JButton("首页");
		btnBWHome.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				init();
			}
		});
		btnBWHome.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBWHome.setBounds(176, 413, 67, 21);
		panelWindows.add(btnBWHome);

		JButton btnBWPrevious = new JButton("上一页");
		btnBWPrevious.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				init();
			}
		});
		btnBWPrevious.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBWPrevious.setBounds(253, 413, 80, 21);
		panelWindows.add(btnBWPrevious);

		JButton btnBWNext = new JButton("下一页");
		btnBWNext.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				init();
			}
		});
		btnBWNext.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBWNext.setBounds(343, 413, 80, 21);
		panelWindows.add(btnBWNext);

		JButton btnBWLast = new JButton("尾页");
		btnBWLast.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				init();
			}
		});
		btnBWLast.setFont(new Font("宋体", Font.PLAIN, 14));
		btnBWLast.setBounds(433, 413, 67, 21);
		panelWindows.add(btnBWLast);

		JPanel panelBusView = new JPanel();
		panelBusView.setFont(new Font("宋体", Font.PLAIN, 16));
		panelRight.addTab("业务情况查看", null, panelBusView, null);
		panelBusView.setLayout(null);

		// 显示数据
		flushData();
		flushBWData();
		StaffData();
	}

	void StaffData() {
		List<Caller> callerList = callerService.findAll();
		// 显示数据到表中
		DefaultTableModel model = (DefaultTableModel) tableStaff.getModel();

		// 清理表中原有的行
		model.setRowCount(0);

		// 重新显示数据到表格中
		for (int i = 0; i < callerList.size(); i++) {
			Caller caller = callerList.get(i);
			Object[] rowData = { caller.getWorkNo(), caller.getName(), caller.getSex(), caller.getHireDate(),
					caller.getBirthDay(), caller.getLastLoginTime(), caller.getLastLoginIp() };

			model.addRow(rowData);
		}
	}

	void flushData() {
		// 重新获取数据库数据，并显示在界面
		// 获取数据
		List<BusinessType> busList = businessTypeService.findAll();

		// 显示数据到表中
		DefaultTableModel model = (DefaultTableModel) tableBusType.getModel();

		// 清理表中原有的行
		model.setRowCount(0);

		// 重新显示数据到表格中
		for (int i = 0; i < busList.size(); i++) {
			BusinessType bus = busList.get(i);
			Object[] rowData = { bus.getId(), bus.getCode(), bus.getName(), bus.getLimitCount(), bus.getDesc() };

			model.addRow(rowData);
		}
	}

	void flushBWData() {
		// 重新获取数据库数据，并显示在界面
		// 获取数据
		List<BusinessWindow> windowList = wDaoService.findAll();
		BWData(windowList);
	}

	void BWData(List<BusinessWindow> windowList) {
		// 显示数据到表中
		DefaultTableModel model = (DefaultTableModel) tableBW.getModel();

		// 清理表中原有的行
		model.setRowCount(0);

		// 重新显示数据到表格中
		for (int i = 0; i < windowList.size(); i++) {
			BusinessWindow window = windowList.get(i);
			Object[] rowData = { window.getId(), window.getNo(), window.getCode(), window.getName() };

			model.addRow(rowData);
		}
	}

	void init() {
		JOptionPane.showMessageDialog(null, "本功能当前本版暂未实现！！！");
	}
}
